﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Practices.Unity;

namespace Skynet.C2SModule.Views.AuthorsDSMgmt
{
    /// <summary>
    /// Interaction logic for AuthorView.xaml
    /// </summary>
    public partial class AuthorView : UserControl, AuthorsDSMgmt.IAuthorView
    {
        public AuthorView()
        {
            InitializeComponent();
            
        }
        [Dependency]
        public IUnityContainer ContainerService { get; set; }




        public string Title
        {
            get { return (string)GetValue(TitleProperty); }
            set { SetValue(TitleProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Title.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(string), typeof(AuthorView), new UIPropertyMetadata("Authors"));


        

        //public Presenters.AuthorsDSMgmt.AuthorDSViewPresenter Presenter { get {
        //    return (Presenters.AuthorsDSMgmt.AuthorDSViewPresenter)this.Resources["Presenter"];
        //} }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {

                //this.ContainerService.BuildUp<Presenters.AuthorsDSMgmt.AuthorDSViewPresenter>(this.Presenter);
                //this.Presenter.OnViewReady(); 

                var ds = (Models.SkynetLibraryDS)this.Resources["skynetLibraryDS"];
                var aadp = new Models.SkynetLibraryDSTableAdapters.AuthorsTableAdapter();
                aadp.Fill(ds.Authors);
                var badp = new Models.SkynetLibraryDSTableAdapters.BooksTableAdapter();
                badp.Fill(ds.Books);
                var authorSource = (System.Windows.Data.CollectionViewSource)this.Resources["authorsViewSource"];
                authorSource.View.MoveCurrentToLast();
                


                //Load your data here and assign the result to the CollectionViewSource.
                
            }
            

            
            
        }
    }
}
